//
// Created by Administrator on 2023/6/3.
//


#include "../header/Descriptive_Widget.h"


Descripttive_Dialog::Descripttive_Dialog(): LDF_Dialog()
    , columns_edit(new QLineEdit()), columns_lable(new QLabel()), ok_button(new QPushButton())
{
    this->Control_Profile();



}


Descripttive_Dialog::~Descripttive_Dialog()
{
    delete columns_lable, columns_edit, ok_button;
}


void Descripttive_Dialog::Control_Profile()
{
    this->columns_lable->setParent(this);
    this->columns_lable->move(145, 70);
    this->columns_lable->resize(100, 30);
    this->columns_lable->setText("列索引序号:");
    this->columns_lable->setObjectName("Columns_Label");
    this->columns_lable->setStyleSheet(columns_label_q);


    this->columns_edit->setParent(this);
    this->columns_edit->move(255, 70);
    this->columns_edit->resize(100, 30);
    this->columns_edit->setObjectName("Columns_Edit");
    this->columns_edit->setStyleSheet(columns_edit_q);


    this->ok_button->setParent(this);
    this->ok_button->move(200, 200);
    this->ok_button->resize(100, 30);
    this->ok_button->setText("确定");
    this->ok_button->setObjectName("OK_Button");
    this->ok_button->setStyleSheet(ok_b_q);

}


Descriptive_Widget::Descriptive_Widget(): LDF_Widget()
    , table(new LDF_Table(1, 7)), data_science(new Data_Science())
{
    this->setAttribute(Qt::WA_DeleteOnClose, false);


    this->Control_Profile();

}


Descriptive_Widget::Descriptive_Widget(QVector<double>* qvec_data): LDF_Widget()
        , table(new LDF_Table(1, 7))
        , qvec_data(qvec_data)
{
    this->setAttribute(Qt::WA_DeleteOnClose, false);


    this->data_science = new Data_Science(qvec_data);


    this->Control_Profile();

}





Descriptive_Widget::~Descriptive_Widget()
{
    delete table, data_science;
}


void Descriptive_Widget::paintEvent(QPaintEvent *event)
{
    LDF_Widget::paintEvent(event);
}


void Descriptive_Widget::paint()
{

}


void Descriptive_Widget::resizeEvent(QResizeEvent *event)
{
    LDF_Widget::resizeEvent(event);
    this->Control_Profile();
}


void Descriptive_Widget::Control_Profile()
{
    this->table->setParent(this);
    this->table->move(5, 30);
    this->table->resize(this->size().width() - 10, this->size().height() - 50);


    QStringList table_column_headers;
    QStringList table_row_headers;
    table_column_headers << "最小值" << "最大值" << "极差" << "众数" << "中位数" << "平均数" << "方差" << "标准差";
    table_row_headers <<  this->select_columns;

    this->table->Get_Model()->setHorizontalHeaderLabels(table_column_headers);
    this->table->Get_Model()->setVerticalHeaderLabels(table_row_headers);

    this->table->Get_Model()->setItem(0, 0, new QStandardItem(QString::number(this->data_science->vec_mini, 'd', 4)));
    this->table->Get_Model()->setItem(0, 1, new QStandardItem(QString::number(this->data_science->vec_max, 'd', 4)));
    this->table->Get_Model()->setItem(0, 2, new QStandardItem(QString::number(this->data_science->vec_range, 'd', 4)));
    this->table->Get_Model()->setItem(0, 3, new QStandardItem(QString::number(this->data_science->vec_mode, 'd', 4)));
    this->table->Get_Model()->setItem(0, 4, new QStandardItem(QString::number(this->data_science->vec_median, 'd', 4)));
    this->table->Get_Model()->setItem(0, 5, new QStandardItem(QString::number(this->data_science->vec_mean, 'd', 4)));
    this->table->Get_Model()->setItem(0, 6, new QStandardItem(QString::number(this->data_science->vec_var, 'd', 4)));
    this->table->Get_Model()->setItem(0, 7, new QStandardItem(QString::number(this->data_science->vec_std, 'd', 4)));

    this->table->setModel(this->table->Get_Model());
}


void Descriptive_Widget::Set_QVec_Data(QVector<double> *qvec_data)
{
    this->qvec_data = qvec_data;
    this->data_science = new Data_Science(qvec_data);
}


Out_Table::Out_Table() {}


Out_Table::~Out_Table() {}